#ifndef PLAYIMAGESWIDGET_H
#define PLAYIMAGESWIDGET_H

#include <QWidget>
#include <QTimer>
#include <QList>
#include <QPixmap>

class PlayImagesWidget : public QWidget
{
    Q_OBJECT
public:
    explicit PlayImagesWidget(QString dir, QWidget *parent = nullptr);
    ~PlayImagesWidget() override;

    void setImageDir(const QString &dir);
    void setLoopPlay(bool loop);
    void setScale(qreal scale);
    void play(int frameRate = 0);
    void stop();

private:
    void loadImages(const QString &dir);

public slots:
    void updateIndex();

protected:
    void paintEvent(QPaintEvent *event) override;

private:
    QTimer *m_timer;
    QString m_imgDir; // 图片目录
    QList<QPixmap> m_imgList; // 图片列表
    int m_curIndex; // 当前播放帧
    int m_frameRate; // 播放帧率
    bool m_loop; // 循环播放
    qreal m_scale; // 缩放系数
};

#endif // PLAYIMAGESWIDGET_H
